package com.music.dao;

import com.laoxuai.beans.annotation.Component;
import com.laoxuai.ibatis.support.BaseDao;
import com.music.pojo.Artist;
import com.music.pojo.Tag;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

@Component
public class ArtistDao extends BaseDao<Artist, Integer> {
//    public int insertrewrite(Artist artist) throws SQLException {
//        String sql = "insert into t_artist values(?,?,?,?,?,?,?,?,?)";
//        Object[] param = {artist.getId(), artist.getName(), artist.getPicUrl(), artist.getBriefDesc(), artist.getArtistOrder(), artist.getMusicSize()
//                , new java.sql.Date(artist.getCreateTime().getTime()), artist.getUpdateTime(), artist.getIsDeleted()};
//        return runner.update(sql, param);
//    }
    public int selectMaxId() throws SQLException {
        String sql="select * from t_artist where id=(\n" +
                "select max(id) from t_artist);";
        Artist reArtist=runner.query(sql, new BeanHandler<Artist>(Artist.class));
        return reArtist.getId();
    }

    public List<Artist> selectAll() throws SQLException {
        String sql = "select * from t_artist";
        return runner.query(sql,new BeanListHandler<Artist>(Artist.class));
    }
}
